<?php
class blog_post_add extends SClass {

    public function process() {
        try {
            if ($this->getControlValue('ok')) {
            	ServiceUtils::GetFactory()->getBlogService()->addPost(
            	   $this->getControlValue('title'),
            	   $this->getControlValue('preview'),
            	   $this->getControlValue('content'),
            	   $this->getUser()->getId()
            	);
            	$this->assign('message', 'ok');
            }
        } catch (ServiceUtils_Exception  $e) {
            $this->assign('errors', $e->getErrors());
        }
    }
}